﻿using System;
using System.Collections.Generic;
using System.Text;

using YouHP.Model;
using YouHP.DALFactory;
using YouHP.Utility;

namespace YouHP.BLL
{
    public class LabcheckBLL
    {
        #region 单件模式
        static LabcheckBLL _Instance;

        public static LabcheckBLL Instance
        {
            get
            {
                if (_Instance == null)
                {
                    _Instance = new LabcheckBLL();
                }
                return _Instance;
            }
        }
        #endregion

        #region 实验室指标增删改查基本操作
        public bool AddLabcheck(LabcheckInfo info)
        {
            return DataAccess.LabcheckDAL.AddLabcheck(info);
        }

        public bool DeleteLabcheck(int[] itemIds)
        {
            return DataAccess.LabcheckDAL.DeleteLabcheck(itemIds);
        }

        public bool UpdateLabcheck(LabcheckInfo info)
        {
            return DataAccess.LabcheckDAL.UpdateLabcheck(info);
        }

#if GENDATA
        public LabcheckInfo GetLabcheckInfo(int did)
        {
            LabcheckInfo info = new LabcheckInfo();
            info.Id = 1;
            info.Name = "谷丙转氨酶";
            info.ShortName = "ALT";
            info.GridValues = "10,50,100,200,1000,3000";
            info.NormalValues = "0@40";
            info.ChartIndex = 0;
            info.AxisIndex = 0;
            info.MeasurementUnits = "U/L";
            return info;
        }
#else

        public LabcheckInfo GetLabcheckInfo(int did)
        {
            return DataAccess.LabcheckDAL.GetLabcheckInfo(did);
        }
#endif
        #endregion

        #region 实验室指标列表以及搜索操作
        /*检索所有实验室指标*/
        public List<LabcheckInfo> GetLabcheckList(int pageSize, int pageIndex, out int count)
        {
            return DataAccess.LabcheckDAL.GetLabcheckList(pageSize, pageIndex, out count);
        }

        /*按照疾病Id检索对应的实验室指标列表*/
        public List<LabcheckInfo> GetLabcheckList(int diseaseId, int pageSize, int pageIndex, out int count)
        {
            return DataAccess.LabcheckDAL.GetLabcheckList(diseaseId, pageSize, pageIndex, out count);
        }

        /*按照疾病Id检索所有对应的实验室指标列表*/
        public List<LabcheckInfo> GetLabcheckList(int diseaseId)
        {
            int count = 0;
            return DataAccess.LabcheckDAL.GetLabcheckList(diseaseId,  Constants.maxPageSize, 1, out count);
        }

        /*按照实验室指标名称来检索症状*/
        public List<LabcheckInfo> GetLabcheckByName(int pageSize, int pageIndex, string keyword, out int count)
        {
            return DataAccess.LabcheckDAL.GetLabcheckByName(pageSize, pageIndex, keyword, out count);
        }

        /*检索后台管理所需要的所有实验室指标列表*/
        public List<LabcheckInfo> GetAllLabcheckByName(string keyword)
        {
            int count = 0;
            return DataAccess.LabcheckDAL.GetLabcheckByName(Constants.maxPageSize, 1, keyword, out count);
        }
        #endregion


    }
}
